#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void Print(int* arr, int n)
{
	for (int i = 0; i < n; i++)
	{
		printf("%d\t", arr[i]);
	}
}

void shell_sort(int* arr, int n)
{
	int gap = 8;
	while (gap>1)
	{
		gap = gap / 2 + 1;
		for (int i = 0; i < n - gap; i++)
		{
			int end = i;
			int temp = arr[end + gap];
			while (end >= 0)
			{
				if (arr[end] > temp)
				{
					arr[end + gap] = arr[end];
					end -= gap;
				}
				else
				{
					break;
				}
			}
			arr[end+gap] = temp;
		}
	}
}

int main()
{
	int arr[] = { 4,6,7,2,65,1,7,2 };
	int n = sizeof(arr) / sizeof(arr[0]);
	shell_sort(arr, n);
	Print(arr, n);

	return 0;
}